package com.baidumap.administrator.happystudy.model;

import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;

import java.io.Serializable;

/**
 * 描述：
 * 作者：xiaoxing on 17/4/12 13:00
 * 邮箱：2235445233@qq.com
 */

@Table(name = "favor")
public class GoodsInfo extends Model implements Serializable, Cloneable {
    /**
     *
     */
    private static final long serialVersionUID = 6851895872936891139L;
    @Column
    String goodsId; // id
    @Column
    String goodsName; // 名称
    @Column
    String goodsIcon; // 图片
    @Column
    String goodsType; // 种类
    @Column
    double goodsPrice; // 价格
    @Column
    String goodsPercent; // 好评
    @Column
    int goodsComment; // 评论人数
    @Column
    int isPhone; // 是否手机专享
    @Column
    int isFavor; // 是否已关注

    @Column
    int rec_id; // 购物车商品的id

    public GoodsInfo() {
    }

    public GoodsInfo(String goodsId, String goodsName, String goodsIcon,
                     String goodsType, double goodsPrice, String goodsPercent,
                     int goodsComment, int isPhone, int isFavor, int rec_id) {
        super();
        this.goodsId = goodsId;
        this.goodsName = goodsName;
        this.goodsIcon = goodsIcon;
        this.goodsType = goodsType;
        this.goodsPrice = goodsPrice;
        this.goodsPercent = goodsPercent;
        this.goodsComment = goodsComment;
        this.isPhone = isPhone;
        this.isFavor = isFavor;
        this.rec_id = rec_id;
    }

    @Override
    public boolean equals(Object obj) {
        GoodsInfo goodsInfo = (GoodsInfo) obj;
        return goodsId.equals(goodsInfo.goodsId) &&
                goodsName.equals(goodsInfo.goodsName) &&
                goodsIcon.equals(goodsInfo.goodsIcon) &&
                goodsType.equals(goodsInfo.goodsType) &&
                goodsPrice == (goodsInfo.goodsPrice) &&
                goodsPercent.equals(goodsInfo.goodsPercent) &&
                goodsComment == (goodsInfo.goodsComment) &&
                isPhone == (goodsInfo.isPhone) &&
                isFavor == (goodsInfo.isFavor) &&
                rec_id == (goodsInfo.rec_id);
    }

    @Override
    public int hashCode() {
        String in = goodsId + goodsName + goodsIcon + goodsType + goodsPrice + goodsPercent + goodsComment + isPhone + isFavor + rec_id;
        return in.hashCode();
    }
//    @Override
//    public int hashCode() {
//        final int prime = 31;
//        int result = 1;
//        result = prime * result + goodsComment;
//        result = prime * result
//                + ((goodsIcon == null) ? 0 : goodsIcon.hashCode());
//        result = prime * result + ((goodsId == null) ? 0 : goodsId.hashCode());
//        result = prime * result
//                + ((goodsName == null) ? 0 : goodsName.hashCode());
//        result = prime * result
//                + ((goodsPercent == null) ? 0 : goodsPercent.hashCode());
//        long temp;
//        temp = Double.doubleToLongBits(goodsPrice);
//        result = prime * result + (int) (temp ^ (temp >>> 32));
//        result = prime * result
//                + ((goodsType == null) ? 0 : goodsType.hashCode());
//        result = prime * result + isFavor;
//        result = prime * result + isPhone;
//        return result;
//    }
//
//    @Override
//    public boolean equals(Object obj) {
//        if (this == obj)
//            return true;
//        if (!super.equals(obj))
//            return false;
//        if (getClass() != obj.getClass())
//            return false;
//        GoodsInfo other = (GoodsInfo) obj;
//        if (goodsComment != other.goodsComment)
//            return false;
//        if (goodsIcon == null) {
//            if (other.goodsIcon != null)
//                return false;
//        } else if (!goodsIcon.equals(other.goodsIcon))
//            return false;
//        if (goodsId == null) {
//            if (other.goodsId != null)
//                return false;
//        } else if (!goodsId.equals(other.goodsId))
//            return false;
//        if (goodsName == null) {
//            if (other.goodsName != null)
//                return false;
//        } else if (!goodsName.equals(other.goodsName))
//            return false;
//        if (goodsPercent == null) {
//            if (other.goodsPercent != null)
//                return false;
//        } else if (!goodsPercent.equals(other.goodsPercent))
//            return false;
//        if (Double.doubleToLongBits(goodsPrice) != Double
//                .doubleToLongBits(other.goodsPrice))
//            return false;
//        if (goodsType == null) {
//            if (other.goodsType != null)
//                return false;
//        } else if (!goodsType.equals(other.goodsType))
//            return false;
//        if (isFavor != other.isFavor)
//            return false;
//        if (isPhone != other.isPhone)
//            return false;
//        return true;
//    }

    public String getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(String goodsId) {
        this.goodsId = goodsId;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getGoodsIcon() {
        return goodsIcon;
    }

    public void setGoodsIcon(String goodsIcon) {
        this.goodsIcon = goodsIcon;
    }

    public String getGoodsType() {
        return goodsType;
    }

    public void setGoodsType(String goodsType) {
        this.goodsType = goodsType;
    }

    public double getGoodsPrice() {
        return goodsPrice;
    }

    public void setGoodsPrice(double goodsPrice) {
        this.goodsPrice = goodsPrice;
    }

    public String getGoodsPercent() {
        return goodsPercent;
    }

    public void setGoodsPercent(String goodsPercent) {
        this.goodsPercent = goodsPercent;
    }

    public int getGoodsComment() {
        return goodsComment;
    }

    public void setGoodsComment(int goodsComment) {
        this.goodsComment = goodsComment;
    }

    public int getIsPhone() {
        return isPhone;
    }

    public void setIsPhone(int isPhone) {
        this.isPhone = isPhone;
    }

    public int getIsFavor() {
        return isFavor;
    }

    public void setIsFavor(int isFavor) {
        this.isFavor = isFavor;
    }

    public int getRec_id() {
        return rec_id;
    }

    public void setRec_id(int rec_id) {
        this.rec_id = rec_id;
    }

    @Override
    public GoodsInfo clone() {
        return new GoodsInfo(goodsId, goodsName, goodsIcon, goodsType, goodsPrice, goodsPercent, goodsComment, isPhone, isFavor, rec_id);
    }
}
